package com.mywork.activity;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ciko.code.base.BaseActicity;
import com.ciko.code.bean.SelAcceptPlanEty;
import com.ciko.code.utils.DateUtil;
import com.image_see.ImageSeeActivity;
import com.mywork.R;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;


/**
 * Created by 12154 on 2015/11/5
 */
public class WorkPlaneDetailActivity
        extends
        BaseActicity
{
	
	private TextView		  tvtypePlane;
	private TextView		  tvtimePlane;
	private TextView		  tvcontectPlane;
	private TextView		  tvsummaryPlane;
	private TextView		  tvnextPlane;
	private TextView		  tvhelpPlane;
	private TextView		  tvremarkPlane;
	private TextView		  tvpersonPlane, tvFujian;
							  
	private TextView		  tvCommentTime;
	private TextView		  tvComment;
							  
	private SelAcceptPlanEty  selAcceptPlanEty;
	private TextView		  tvHeadImgName, tvHeadCommentName;
	private LinearLayout	  llHelp, llRemarks;
	private TextView		  tvContectPlan, tvTheNextPlan;
	private ImageView		  imgPic;
	private ArrayList<String> urlList = new ArrayList<>();
									  
	@Override
	protected void initTopBar() {
		selAcceptPlanEty = (SelAcceptPlanEty) getIntent().getSerializableExtra("SelAcceptPlanEty");
		
		setTitle("计划详情");
		enableNavLeftImg();
	}
	
	@Override
	protected void initLayout() {
		setContentView(R.layout.activity_work_plane_detail);
	}
	
	@Override
	protected void initView() {
		tvContectPlan = (TextView) findViewById(R.id.tv_contectPlane1);
		tvTheNextPlan = (TextView) findViewById(R.id.tv_nextPlane1);
		llHelp = (LinearLayout) findViewById(R.id.ll_help);
		llRemarks = (LinearLayout) findViewById(R.id.ll_remarks);
		tvHeadImgName = (TextView) findViewById(R.id.tv_head_img_name);
		tvHeadCommentName = (TextView) findViewById(R.id.tv_head_comment_name);
		tvpersonPlane = (TextView) findViewById(R.id.tv_personPlane);
		tvremarkPlane = (TextView) findViewById(R.id.tv_remarkPlane);
		tvhelpPlane = (TextView) findViewById(R.id.tv_helpPlane);
		tvnextPlane = (TextView) findViewById(R.id.tv_nextPlane);
		tvsummaryPlane = (TextView) findViewById(R.id.tv_summaryPlane);
		tvcontectPlane = (TextView) findViewById(R.id.tv_contectPlane);
		tvtimePlane = (TextView) findViewById(R.id.tv_timePlane);
		tvtypePlane = (TextView) findViewById(R.id.tv_typePlane);
		tvCommentTime = (TextView) findViewById(R.id.tv_detail_commit_time);
		tvComment = (TextView) findViewById(R.id.tv_text_comm);
		imgPic = (ImageView) findViewById(R.id.img_pic);
		tvFujian = (TextView) findViewById(R.id.tvFujian);
		
	}
	
	@Override
	protected void initAdapter() {
	
	}
	
	@Override
	protected void initDates() {
		tvHeadImgName.setText(selAcceptPlanEty.getCreateName());
		tvHeadCommentName.setText(selAcceptPlanEty.getAcceptName());
		tvpersonPlane.setText(selAcceptPlanEty.getAcceptName());
		tvremarkPlane.setText((selAcceptPlanEty.getRemarks() == null ? "" : selAcceptPlanEty.getRemarks()));
		tvhelpPlane.setText((selAcceptPlanEty.getHelp() == null ? "" : selAcceptPlanEty.getHelp()));
		tvnextPlane.setText((selAcceptPlanEty.getWorkPlan() == null ? "" : selAcceptPlanEty.getWorkPlan()));
		tvsummaryPlane.setText((selAcceptPlanEty.getWorkSummary() == null ? "" : selAcceptPlanEty.getWorkSummary()));
		tvcontectPlane.setText((selAcceptPlanEty.getCompleteWork() == null ? "" : selAcceptPlanEty.getCompleteWork()));
		tvtimePlane.setText("提交时间:" + DateUtil.longToDate(selAcceptPlanEty.getCreateTime(), 8));
		llRemarks.setVisibility(selAcceptPlanEty.getRemarks() == null || selAcceptPlanEty.getRemarks().equals("") ? View.GONE : View.VISIBLE);
		llHelp.setVisibility(selAcceptPlanEty.getHelp() == null || selAcceptPlanEty.getHelp().equals("") ? View.GONE : View.VISIBLE);
		if (selAcceptPlanEty.getEnclosure().equals(""))
		{
			imgPic.setVisibility(View.GONE);
			tvFujian.setVisibility(View.GONE);
		}
		else
		{
			Picasso.with(this).load(selAcceptPlanEty.getEnclosure()).placeholder(R.drawable.bg_small_image).into(imgPic);
			urlList.add(selAcceptPlanEty.getEnclosure());
		}
		switch (selAcceptPlanEty.getPlanType()) {
			case "周报":
				tvtypePlane.setText("周报");
				tvContectPlan.setText("本周工作情况：");
				tvTheNextPlan.setText("下周工作计划：");
				break;
			case "月报":
				tvtypePlane.setText("月报");
				tvContectPlan.setText("本月工作情况：");
				tvTheNextPlan.setText("下月工作计划：");
				break;
			case "季报":
				tvtypePlane.setText("季报");
				tvContectPlan.setText("本季工作情况：");
				tvTheNextPlan.setText("下季工作计划：");
				break;
				
		}
		
		tvCommentTime.setText(getString(R.string.approval_time, selAcceptPlanEty.getModifyTimeStr()));
		tvComment.setText(selAcceptPlanEty.getComment());
		tvCommentTime.setVisibility(selAcceptPlanEty.getStatus().equals("1") ? View.GONE : View.VISIBLE);
	}
	
	@Override
	protected void initListener() {
		imgPic.setOnClickListener(new View.OnClickListener()
		{
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(WorkPlaneDetailActivity.this, ImageSeeActivity.class);
				intent.putStringArrayListExtra("urlList", urlList);
				startActivity(intent);
			}
		});
	}
	
}
